﻿<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Inputstream Data Viewer</title>
    <link rel="stylesheet" href="../../../../lib/bootstrap/3.3.5/css/bootstrap.min.css"/>
    <!--
    <link rel="stylesheet" href="tasks-v2.css">
	-->
</head>
<body>
	<div id="queryinput" class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<h3 class="page-header text-center">
					V2V 不同距离下的丢包率测试报告（Lostrate vs. Distance）
				</h3>
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6">
				<form class="form-horizontal contract-form">
					<!--
					<fieldset>
						<legend><small>请输入查询条件</small></legend>
					-->

					<!--
					<div class="form-group">
						<h5>
						<label class="col-sm-3 control-label" style="text-align:left">请输入查询条件</label>
						</h5>
					</div>
					<hr/>
					-->
					<div class="form-group">
						<label class="col-sm-1 control-label">Distance</label>
						<div class="col-sm-4">
							<input id="distance" name="id" type="text" class="form-control contact-name-input" v-model="distance"/>
						</div>
						<label class="col-sm-2 control-label">Velocity</label>
						<div class="col-sm-4">
							<input id="velocity" name="name" type="text" class="form-control contact-name-input" v-model="velocity" required />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">Name</label>
						<div class="col-sm-4">
							<input type="text" id="name" name="name" value="<%= name %>"
								class="form-control contact-name-input" required />
						</div>
						<label class="col-sm-2 control-label">Name</label>
						<div class="col-sm-4">
							<input type="text" id="name" name="name" value="<%= name %>"
								class="form-control contact-name-input" required />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">Grapes</label>
						<div class="col-sm-4">
							<input type="text" id="grapes" name="grapes"
								class="form-control contact-name-input" disabled value="<%= grapes %>" />
						</div>
						<label class="col-sm-2 control-label">Grapes</label>
						<div class="col-sm-4">
							<input type="text" id="grapes" name="grapes"
								class="form-control contact-name-input" value="<%= grapes %>" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">Region</label>
						<div class="col-sm-4">
							<input type="text" id="region" name="region" class="form-control contact-name-input" value="<%= region %>" />
						</div>
						<label class="col-sm-2 control-label">Year</label>
						<div class="col-sm-4">
							<input type="text" id="year" name="year"
								class="form-control contact-name-input" value="<%= year %>" />
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-1 control-label">Notes</label>
						<div class="col-sm-10">
							<textarea id="description" name="description"
								class="form-control contact-name-input"><%= description %></textarea>
						</div>
					</div>
					<hr />
					<div class="form-group">
						<div class="col-sm-offset-6 col-sm-2">
							<button class="btn btn-outline btn-block btn-warning" v-on="click:cancel(item,$event)">取消</button>
						</div>
						<div class="col-sm-3">
							<!--
							<button id='submitbutton' type="submit" class="btn btn-outline btn-lg btn-block save">Submit</button>
							-->
							<button id='submitbutton' class="btn btn-outline btn-block btn-success save" v-on="click:execute(item,$event)">提交</button>
						</div>

					</div>
					<!--
					</fieldset>
					-->
				</form>
			</div>
			<div class="span6">
			</div>
		</div>
		<div class="row-fluid">
			<div class="col-sm-12">
			请输入查询条件，点击提交按钮生成统计报告。报告生成可能需要较长时间，请耐心等待...
			</div>
			<div class="span4">
			</div>
		</div>
		<hr/>
		<div>
		   <h1>json添加用户----test backend json processing</h1>
			姓名：<input id="userName" type="text" name="userName">
			年龄:<input id="age" type="text" name="age"><br>
			<input type="button" id="resolveJsonObject" value="json对象">
			<input type="button" id="resolveJsonArray" value="json数组">
			<input type="button" id="resolveJson" value="前端解析json字符串">
		</div>
	</div>

    <script src="../../../../lib/jquery/2.1.4/jquery-2.1.4.min.js"></script>
    <script src="../../../../lib/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script src="../../../../lib/underscore/underscore-min.js"></script>
	<script src="../../../../node_modules/backbone/backbone-min.js"></script>
    <script src="../../../../node_modules/vue/dist/vue.js"></script>
    <script src="report-template-v3.js"></script>

	<!-- test backend json processing only. should be deleted in released version -->
	<script type="text/javascript">

    $(document).ready(function(){
        //传递字符串格式json对象到后台（一个json对象）
        $("#resolveJsonObject").click(function(){
            var userName =encodeURI($("#userName").attr("value"));
            var age = encodeURI($("#age").attr("value"));

            var user = {userName:userName,age:age};
            var aMenu  = encodeURI(JSON.stringify(user));

            $.ajax({
                 url:"../../rest/reportworker/rept0001" ,
                 data:"search=" + aMenu,
                 success:function(data){
					alert(data);
                }
            });
        });

        //传递json数组到后台
        $("#resolveJsonArray").click(function(){
            var userName =encodeURI($("#userName").attr("value"));
            var age = encodeURI($("#age").attr("value"));

            //数组开始
            var user1 = {userName:userName,age:age};
            var allMenu={
                "menu":[ ]
                };
            allMenu.menu.push(user1);
            var allMenu1 = encodeURI(JSON.stringify(allMenu));

            $.ajax({
                //json数组
                 url:"/springMVC6/user/data/resolveJsonArray" ,
                data:"orderJson=" + allMenu1,
                success:function(data){

                }
            });
        });

        //接收后台的json在前台解析
        $("#resolveJson").click(function(){

            $.ajax({
                //解析从后台返回的json数据
                url:"/springMVC6/user/data/resolveJson" ,
                type:"post",
                success:function(data){
                    var arr=eval(data);
                    alert(arr.length);
                    for(var m = 0;m<arr.length;m++){
                        alert(arr[m].user.userName);
                    }
                }
            });
        });


        var state=1;
        window.setInterval(function(){

        if(state==1)
         {
         	//console.log('aaaaaaaa');
         	state=0;
         }else
         {
         	//window.open('http://openwsn.tongji.edu.cn:8080/site')//console.log('bbbbbbbb');
         	state=1;
         }

        }, 5000);



    });

	</script>
</body>
</html>
